const commandClassMapping = {
  'new-file': require('./NewFileCommand'),
  'open-file': require('./OpenFileCommand'),
  'save-file': require('./SaveFileCommand'),
  'save-as-view': require('./SaveAsViewCommand'),

  'config': require('./ConfigCommand')
};

const commandInstanceMapping = {};

module.exports = function load(command) {
  const commandInstance = commandInstanceMapping[command];
  if (commandInstance) {
    return commandInstance;
  }

  const CommandClass = commandClassMapping[command];
  if (CommandClass) {
    const newCommandInstance = new CommandClass();
    commandInstanceMapping[command] = newCommandInstance;
    return newCommandInstance;
  }
  return null;
};
